package com.tarena.test.rabbitmq.queue;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import org.junit.Before;
import org.junit.Test;

//专门用来测试 队列参数
public class QueueArguments {
    private Channel channel;
    @Before
    public void initChannel() throws IOException, TimeoutException {
        ConnectionFactory factory=new ConnectionFactory();
        factory.setHost("localhost");
        factory.setPort(5672);
        factory.setUsername("guest");
        factory.setPassword("guest");
        factory.setVirtualHost("/");
        Connection connection= factory.newConnection();
        channel=connection.createChannel();
    }
    //声明一个 有超时时间 10秒的队列
    @Test
    public void declareExpiredQueue() throws IOException {
        Map<String,Object> args=new HashMap<>();
        args.put("x-expires",10000);
        channel.queueDeclare("expired-queue", false, false, false, args);
    }
}
